<!-- INCLUDE cms/output/header_body.html -->

<!-- INCLUDE cms/menu/output/option_bar_body.html -->

<section class="full-content">
	<form method="post" action="cms.php?p=menu&act=add" id="form-add-menu">
		<article>
			<div class="head">Add a new menu item</div>
			<div class="form-box">
				<div class="row">
					<div class="left">Menu title:</div>
					<div class="right">
						<input type="text" name="title" value="" />
					</div>
				</div>
				
				<div class="row">
					<div class="left">Page:</div>
					<div class="right">
						<select name="page_id">
							<option value="0" selected="selected">No page</option>
						</select>
					</div>
				</div>
				
				<div class="row">
					<div class="left">Target:</div>
					<div class="right">
						<select name="target">
							<option value="_self" selected="selected">Same Window</option>
							<option value="_blank">New Window</option>
							<option value="_tab">New Tab</option>
						</select>
					</div>
				</div>
				
				<div class="row">
					<div class="left">Link:</div>
					<div class="right">
						<input type="text" name="mlink" value="" />
					</div>
				</div>
				
				<div class="row">
					<div class="left">Language</div>
					<div class="right">
						<select name="language">
							<option value="en" selected="selected">English</option>
						</select>
					</div>
				</div>
			</div>
		</article>
		
		<article>
			<div class="head">Actions</div>
			<div class="content">
				<div class="form-box">			
					<div class="row">
						<div class="single">
							<input type="submit" name="submit" id="page_submit" value="Opslaan" />
							<input type="reset" name="reset" value="Reset" />
						</div>
					</div>
				</div>
			</div>
		</article>
	</form>
	
	<article>
		<a class="close-window hover">Close Window</a>
	</article>
</section>

<script type="text/javascript">
$('.close-window').click(function(){
	$.unblockUI();	
});

$("#form-add-menu").submit(function(event){
	event.preventDefault();

	var $form	= $(this),
	menuTitle	= $form.find('input[name="title"]').val(),
	menuPage 	= $form.find('select[name="page_id"]').val(),
	menuTarget 	= $form.find('input[name="target"]').val(),
	menuLink 	= $form.find('input[name="mlink"]').val(),
	menuLang 	= $form.find('select[name="language"]').val(),
	url			= $form.attr('action');
	
	var posting = $.post(url, {title:menuTitle, page_id:menuPage, target:menuTarget, mlink:menuLink, language:menuLang, submit:true});
	
	posting.done(function(data){
		alert('Yo');
		var content = $(data).find('#content');
		$('#result').empty().append(content);
		$.unblockUI();	
		$.growlUI('Succes!', 'Menu Item ' + menuTitle + ' has been succesfully added!');
		$('#full').load('cms.php?p=menu&ajax=true');
	});
});
	
</script>

<!-- INCLUDE cms/output/footer_body.html -->